<?php
include_once('../lib/config.php');
include_once('../lib/Db.class.php');
include_once('../lib/Model.class.php');
include_once('../lib/Upyun.class.php');
include_once('../lib/function.php');

$redis = new Redis();
$redis->connect(REDIS_IP, "6379");  //php客户端设置的ip及端口
if(!$redis) die('redis connect fail');
$redis->auth(REDIS_PASS);

$model = new Model;

$since_id = 0;
while(true) {
  	$stop = $redis->get('LNPAN_QUEUE_STOP');
  	if($stop) {
    	die('stop');
  	}

  	$sql  = "select id from yl_news 
						where id > $since_id AND state = 4 
						order by id asc
						limit 100 
		";
    $news_list = $model->query($sql);
  	if(!$news_list) {
  		die('empty');
  	}

  	foreach ($news_list as $news) {
  		$redis->rPush(LIUDOUMI_YUN_QUEUE, $news['id']);
  		$since_id = $news['id'];
  		var_dump($since_id . '/' . $redis->lSize(LIUDOUMI_YUN_QUEUE));
  	}

  	usleep(100000);
}